package com.kejiguan.ui.response;

import android.text.TextUtils;
import android.util.Log;

import com.google.gson.annotations.Expose;
import com.kejiguan.ui.event.RefreshNeStateEvent;
import com.kejiguan.ui.model.DisplayArea;
import com.kejiguan.ui.model.ExhibitionNeItem;
import com.kejiguan.ui.util.CacheDataUtil;
import com.kejiguan.ui.util.CommonDate;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by YYY on 16/7/9.
 */
public class AlarmResponse extends BaseResponse{


    @Expose
    private String alarmContent;


    public String getAlarmContent() {
        return alarmContent;
    }

    public void setAlarmContent(String alarmContent) {
        this.alarmContent = alarmContent;
    }


    public void resetExhibitionState()
    {
        if (!TextUtils.isEmpty(alarmContent))
        {
            if (null!=CacheDataUtil.getInstance().getDisplayAreas())
            {
                for (DisplayArea displayArea: CacheDataUtil.getInstance().getDisplayAreas())
                {
                    Log.d(AlarmResponse.class.getSimpleName(),"DisplayArea:"+displayArea.getDisplayName());
                    for (ExhibitionNeItem exhibitionNeItem:displayArea.getExhibitionNeItems())
                    {
                        if (alarmContent.indexOf(exhibitionNeItem.getExhibitionName())!=-1)
                        {
                            CacheDataUtil.getInstance().getOperationRecord().remove(exhibitionNeItem.getExhibitionId());
                            exhibitionNeItem.setExhibitionState(CommonDate.STATE_EXCEPTION);
                            EventBus.getDefault().post(new RefreshNeStateEvent());
                        }
                    }
                }
            }

        }

    }
}
